#include<stdio.h>
#include<string.h>
#include<unistd.h>
#include<signal.h>

struct sigaction act,oact;
void handler(int signo){
    printf("get a signal:%d\n",signo);
    sigaction(2,&oact,NULL);
}
int main(){
    //1.初始化两个sigaction
    memset(&act,0,sizeof(act));
    memset(&oact,0,sizeof(oact));
    //2.填act内容
    act.sa_flags = 0;
    act.sa_handler = handler;
    sigemptyset(&act.sa_mask);
    //3.调用sigaction函数
    sigaction(2,&act,&oact);
    //4.死循环打印
    while(1){
        printf("i am processing\n");
        sleep(1);
    }
    return 0;
}